// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/fushnisoft/SublimeClarion>
// and licensed `mit`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
 * @import {Grammar} from '@wooorm/starry-night'
 */

/** @type {Grammar} */
const grammar = {
  extensions: ['.clw'],
  names: ['clarion'],
  patterns: [
    {include: '#comments'},
    {include: '#classLabels'},
    {include: '#labels'},
    {include: '#langConstants'},
    {include: '#langProps'},
    {include: '#langFunctions'},
    {include: '#userVars'},
    {include: '#implicits'},
    {include: '#hardReservedKeywords'},
    {include: '#softReservedKeywords'},
    {include: '#directives'},
    {include: '#baseTypes'},
    {include: '#specialTypes'},
    {include: '#strings'},
    {include: '#attributes'},
    {include: '#operators'},
    {include: '#currencyInPicture'},
    {include: '#numericConstants'}
  ],
  repository: {
    attributes: {
      match:
        '\\b(?i:ABOVE|ABSOLUTE|ALONE|ALRT|ANGLE|AT|AUTO|AUTOSIZE|AVE|BELOW|BEVEL|BINARY|BINDABLE|BITMAP|BOXED|C|CAP|CENTER|CENTERED|CNT|COLOR|COLUMN|COM|COMPATIBILITY|CONST|CURSOR|DEFAULT|DELAY|DERIVED|DIM|DLL|DOCUMENT|DOCK|DOCKED|DOWN|DRAGID|DRIVER|DROP|DROPID|DUP|ENCRYPT|EXPAND|EXTEND|EXTERNAL|FILL|FILTER|FIRST|FIX|FIXED|FLAT|FONT|FROM|FULL|GLOBALCLASS|GRAY|GRID|HIDE|HLP|HSCROLL|HVSCROLL|ICON|ICONIZE|IMM|IMPLEMENTS|INNER|INS|LANDSCAPE|LAST|LATE|LAYOUT|LENGTH|LFT|LINEWIDTH|LINK|LOCATE|MARK|MASK|MAX|MAXIMIZE|MDI|META|MIN|MM|MODAL|MSG|NAME|NOBAR|NOCASE|NOFRAME|NOMEMO|NOMERGE|NOSHEET|OEM|OPT|ORDER|OUTER|OVER|OVR|OWNER|PAGE|PAGEAFTER|PAGEBEFORE|PALETTE|PAPER|PASCAL|PASSWORD|POINTS|PRE|PREVIEW|PRIMARY|PRIVATE|PROC|PROTECTED|RANGE|RAW|READONLY|RECLAIM|REPEAT|REPLACE|REQ|RESIZE|SCROLL|SINGLE|SMOOTH|SPREAD|STATIC|STD|STEP|STRETCH|SUM|SUPPRESS|TALLY|TARGET|THOUS|TILED|TIMER|TIP|TOGETHER|TOOLBOX|TRN|UP|UPR|USE|VALUE|VERTICAL|VCR|VIRTUAL|VSCROLL|WALLPAPER|WIDTH|WITHNEXT|WITHPRIOR|WIZARD|WRAP|ZOOM|CHECK|DOUBLE|SEPARATOR|PAGENO|RTF|SYSTEM|TYPE|COM|)\\b',
      name: 'entity.other.attribute-name.clarion'
    },
    baseTypes: {
      match:
        '\\b(?i:ANY|ASTRING|BFLOAT4|BFLOAT8|BLOB|MEMO|BOOL|BSTRING|BYTE|CSTRING|DATE|DECIMAL|DOUBLE|FLOAT4|LONG|LIKE|PDECIMAL|PSTRING|REAL|SHORT|SIGNED|SREAL|STRING|TIME|ULONG|UNSIGNED|USHORT|VARIANT)\\b',
      name: 'storage.type.base-types.clarion'
    },
    classLabels: {
      captures: {1: {name: 'entity.other.inherited-class.clarion'}},
      match: '^[A-Za-z_][A-Za-z0-9_:]*\\.([A-Za-z_][A-Za-z0-9_:\\.]*)\\s',
      name: 'entity.name.class.clarion'
    },
    comments: {match: '(\\!|\\|).*', name: 'comment.line.clarion'},
    currencyInPicture: {
      begin: '@[Nn][\\-]?[0-9\\.]*\\~',
      end: '\\~',
      name: 'constant.numeric.clarion'
    },
    directives: {
      match:
        '\\b(?i:ASSERT|BEGIN|COMPILE|EQUATE|INCLUDE|ITEMIZE|OMIT|ONCE|SECTION|SIZE)\\b',
      name: 'storage.modifier.directives.clarion'
    },
    hardReservedKeywords: {
      match:
        '\\b(?i:ACCEPT|AND|BREAK|BY|CASE|CHOOSE|CYCLE|DO|ELSE|ELSIF|END|EXECUTE|EXIT|FUNCTION|GOTO|IF|LOOP|MEMBER|NEW|NOT|OF|OR|OROF|PARENT|PROCEDURE|PROGRAM|RETURN|ROUTINE|SELF|THEN|TIMES|TO|UNTIL|WHILE)\\b',
      name: 'keyword.clarion'
    },
    implicits: {
      captures: {1: {name: 'constant.numeric.implicit.clarion'}},
      match: '([A-Za-z][A-Za-z0-9_]+)(\\$|#|")',
      name: 'keyword.implicit.clarion'
    },
    labels: {
      match: '^([A-Za-z_][A-Za-z0-9_:\\.]*)\\s',
      name: 'entity.name.function.clarion'
    },
    langConstants: {
      match: '\\b(?i:TRUE|FALSE|NULL)\\b',
      name: 'support.constant.clarion'
    },
    langFunctions: {
      match:
        '\\b(?i:ADD|DISPOSE|ADDRESS|GET|BAND|BUILD|CLEAR|CLOSE|DELETE|DUPLICATE|FIXFORMAT|FREESTATE|GETNULLS|GETSTATE|HOLD|LOCK|MAXIMUM|OPEN|POINTER|POSITION|PUT|RECORDS|REGET|RESET|RESTORESTATE|SET|SETNULLS|STATUS|UNBIND|UNFIXFORMAT|_PROC|_PROC1|_PROC2|_PROC3|ACCEPTED|ACOS|ALERT|ALIAS|ALL|ARC|ASIN|ASK|ATAN|BEEP|BINDEXPRESSION |BLANK|BOF|BOX|BUFFER|BYTES|CALL|CENTER|CHAIN|CHANGE|CHANGES|CHOICE|CHORD|CLIP|CLIPBOARD|CLOCK|CLONE|COLORDIALOG|COMMAND|COMMIT|COMPRESS |CONVERTANSITOOEM|CONVERTOEMTOANSI|CONTENTS|COPY|COS|DATE|DAY|DEBUGHOOK|DECOMPRESS |DELETEREG|DESTROY|DIRECTORY|DIRECTORY|DISABLE|DISPLAY|DRAGID|DROPID|ELLIPSE|EMPTY|ENABLE|ENDPAGE|EOF|ERASE|ERROR|ERRORCODE|ERRORFILE|EVALUATE|EXISTS|FIELD|FILEDIALOG|FILEDIALOGA|FILEERROR|FILEERRORCODE|FIRSTFIELD|FLUSH|FOCUS|FONTDIALOG|FONTDIALOGA|FORWARDKEY|FREE|FREEZE|GETEXITCODE|GETFONT|GETGROUP|GETREG|GETREGSUBKEYS|GETREGVALUES|GETINI|GETPOSITION|HALT|HELP|HIDE|HOWMANY|IDLE|IMAGE|INCOMPLETE|INSTANCE|INSTRING|ISALPHA|ISGROUP|ISLOWER|ISUPPER|ISSTRING|KEYBOARD|KEYCHAR|KEYCODE|KEYSTATE|LASTFIELD|LEFT|LEN|LINE|LOCALE|LOCKTHREAD|LOG10|LOGE|LONGPATH|LOWER|MATCH|MESSAGE|MONTH|MOUSEX|MOUSEY|NAME|NEXT|NOMEMO|NOTIFICATION|NOTIFY|NUMERIC|PACK|PATH|PENCOLOR|PENWIDTH|PENSTYLE|PIE|POLYGON|POPBIND|POPERRORS|POPUP|POST|PRESS|PRESSKEY|PREVIOUS|PRINTERDIALOG|PRINTERDIALOGA|PUSHBIND|PUSHERRORS|PUTREG|PUTINI|QUOTE|RANDOM|REGISTER|REGISTEREVENT|EVENT|RELEASE|REMOVE|RESUME|RIGHT|ROLLBACK|ROUNDBOX|RUN|RUNCODE|REJECTCODE|SELECT|SELECTED|SEND|SET3DLOOK|SETCLIPBOARD|SETCLOCK|SETCOMMAND|SETCURSOR|SETDROPID|SETEXITCODE|SETFONT|SETFONT|SETKEYCHAR|SETKEYCODE|SETLAYOUT|SETPATH|SETPENWIDTH|SETPENSTYLE|SETPENCOLOR|SETPOSITION|SETPOSITION|SETTARGET|SETTODAY|SHARE|SHORTPATH|SHOW|SHUTDOWN|SIN|SKIP|SQRT|START|STATUS|STOP|STREAM|STRPOS|SUB|SUSPEND|TAN|THREAD|THREADLOCKED|TIE|TIED|TODAY|TYPE|UNFREEZE|UNHIDE|UNLOAD|UNLOCK|UNLOCKTHREAD|UNQUOTE|UNREGISTER|UNREGISTEREVENT|UNTIE|UPDATE|UPPER|WATCH|WHAT|WHAT|WHERE|WHERE|WHO|WHO|YEAR|YIELD|ABS|AFTER|AGE|APPEND|BEFORE|BIND|BINDEXPRESSION|BOR|BSHIFT|BXOR|CHR|COMPRESS|CREATE|DDEACKNOWLEDGE|DDEAPP|DDECHANNEL|DDECLIENT|DDECLOSE|DDEEXECUTE|DDEITEM|DDEPOKE|DDEQUERY|DDEREAD|DDESERVER|DDETOPIC|DDEVALUE|DDEWRITE|DECOMPRESS|DEFORMAT|FILEEXISTS|FORMAT|FULLNAME|INLIST|INRANGE|INT|LOGOUT|OCXLOADIMAGE|OCXREGISTEREVENTPROC|OCXREGISTERPROPCHANGE|OCXREGISTERPROPEDIT|OCXSETPARAM|OCXUNREGISTEREVENTPROC|OCXUNREGISTERPROPCHANGE|OCXUNREGISTERPROPEDIT|OLEDIRECTORY|OMITTED|PEEK|POKE|PRAGMA|PRINT|PRINTER|RENAME|ROUND|SAVEDIALOG|SETNONULL|SETNULL|SHIFT|SORT|VAL|XOR)\\b',
      name: 'support.function.clarion'
    },
    langProps: {
      match:
        '\\b(?i:PROP|PROPLIST|EVENT|COLOR|CREATE|BRUSH|FILE|LEVEL|STD|CURSOR|ICON|BEEP|REJECT|FONT|CHARSET|PEN|LISTZONE|BUTTON|MSGMODE|WINDOW|TEXT|FREEZE|DDE|FF_|OCX|DOCK|MATCH|PAPER|DRIVEROP|DATATYPE|GradientTypes):\\w*\\b',
      name: 'support.constant.clarion'
    },
    numericConstants: {
      match:
        '\\b(([0-9][0-9a-fA-F]*(h|H))|([0-1]*(b|B))|([0-7]*(o|O))|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)\\b',
      name: 'constant.numeric.clarion'
    },
    operators: {
      match:
        '\\?|\\{|\\}|\\+|\\-|\\*|\\*\\*|/|//|%|<|>|&|\\||\\^|~|=|:=:|,|\\(|\\)',
      name: 'keyword.operator.clarion'
    },
    softReservedKeywords: {
      match:
        '\\b(?i:APPLICATION|CLASS|CODE|DATA|DETAIL|ENUM|FILE|FOOTER|FORM|GROUP|HEADER|INLINE|ITEM|JOIN|MAP|MENU|MENUBAR|MODULE|OLECONTROL|OPTION|QUEUE|RECORD|REPORT|ROW|SHEET|STRUCT|TAB|TABLE|TOOLBAR|VIEW|WINDOW|PROPERTY|INDEXER)\\b',
      name: 'entity.name.tag.clarion'
    },
    specialTypes: {
      match:
        '\\b(?i:APPLICATION|BUTTON|CHECK|CLASS|COMBO|CUSTOM|DETAIL|ELLIPSE|ENTRY|FILE|FOOTER|FORM|GROUP|HEADER|IMAGE|INTERFACE|ITEM|KEY|INDEX|LINE|LIST|MENU|MENUBAR|OCX|OLE|OPTION|PANEL|PROGRESS|PROJECT|PROMPT|QUEUE|RADIO|REGION|REPORT|SEPARATOR|SHEET|SPIN|TAB|TABLE|TEXT|TOOLBAR|VBX|VIEW)\\b',
      name: 'storage.type.specialTypes.clarion'
    },
    strings: {begin: "\\'", end: "\\'", name: 'string.quoted.single.clarion'},
    userVars: {
      match: '\\b(?i:LOC|GLO):\\w*\\b',
      name: 'variable.parameter.clarion'
    }
  },
  scopeName: 'source.clarion'
}

export default grammar
